package jgrit.options;

/**
 * 
 * @author Taylor Perkins
 *
 */
public class RangedIntOption extends Option {
	
	int minValue, maxValue;
	
	/* Constructor */
	public RangedIntOption(String name, String group,
			String initialValue, int minValue, int maxValue) {
		super(name, group, initialValue);
		this.minValue = minValue;
		this.maxValue = maxValue;
	}
	
	/* (non-Javadoc)
	 * @see jgrit.options.Option#validate()
	 */
	@Override
	public boolean validate() {
		try {
			if (Integer.parseInt(this.getValue()) <= maxValue && 
					Integer.parseInt(this.getValue()) >= minValue) {
				return true;
			}
		}
		catch (NumberFormatException ex) {
			return false;
		}
		return false;
	}
	
	/* (non-Javadoc)
	 * @see jgrit.options.Option#isCharValid()
	 */
	@Override
	public boolean isCharValid(char c) {
		return (Character.isDigit(c));
	}
}
